<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="vue.js"></script>
</head>
<body>
    <div id="app">
        <h1>{{msg}}</h1>
        <my-com :msg='msg'></my-com>
    </div>  

    
    <script type="text/html" id="sub">
        <div>
            <p>{{txt}}</p>
            <p>{{msg}}</p>
        </div>
    </script>
    
    <script>
        Vue.component('my-com',{
            template:'#sub',
            data:function(){
                return {
                    txt:'我是子组件的数据'
                }
            },
            props:['msg']
        })
        var app = new Vue({
            el:'#app',
            data:{
                msg:'我是父组件的数据'
            }
        })
    </script>
</body>
</html>